package iot.ht.controller.htplat;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import iot.core.annotation.Auth;
import iot.core.annotation.Log;
import iot.core.data.IdNameDto;
import iot.core.data.mapper.HTPlatMapper;
import iot.core.enums.AuthType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/htplat")
@Tag(name = "平台", description = "")
public class HTPlatController {
    @Autowired
    HTPlatMapper htPlatMapper;

    @Auth(authType = AuthType.Login)
    @Log(logNeed = false,logTemplete ="",logPin = true,logPout = true)
    @PostMapping("/list")
    @Operation(summary = "平台列表", description = "")
    public List<IdNameDto> list( )   {
         var qw=htPlatMapper.getQueryWrapper();
         qw.select("Id","Name");
         qw.orderBy(true,true,"Id");
         var lmap=htPlatMapper.selectMaps(qw);
         var r=new ArrayList<IdNameDto>();
         for(var map:lmap){
             var mm=new IdNameDto();
             mm.setId( (Long)map.get("Id") );
             mm.setName((String)map.get("Name"));
             r.add(mm);
         };
         return r;
    }



}
